package com.strongdigit.ioc.beanannotation.jsr;

import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;

//@Service
@Named
public class jsrService {

    //    @Resource
  //  @Inject
    private JsrDAO jsrDao;

//    @Resource
    @Inject
    public void setJsrDao(@Named("jsrDAO")JsrDAO jsrDao) {
        this.jsrDao = jsrDao;
    }

    //@Resouce 初始化之后调用的方法
    @PostConstruct
    public void init() {
        System.out.println("初始化之后的方法调用");

    }

    //@Resource 销毁之前的调用的方法
    @PreDestroy
    public void destory() {
        System.out.println("销毁之前方法调用");
    }

    public void save() {
        jsrDao.save();
    }
}
